//
//  ByRecordWorkListCell.m
//  recordworktool_ios
//
//  Created by mc on 2017/12/9.
//  Copyright © 2017年 ZhangZhanbin. All rights reserved.
//

#import "ByRecordWorkListCell.h"

@implementation ByRecordWorkListCell

+ (instancetype)cellWithTableView:(UITableView*)tableView {
    
    static NSString *cellIdentifier = @"ByRecordWorkListCell";
    ByRecordWorkListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
    
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self createViews];
    }
    return self;
}


- (void)createViews{
    
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    UIView *view = [[UIView alloc] init];
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(self.contentView).offset(0);
        make.bottom.equalTo(self.contentView).offset(-5);
    }];
    view.backgroundColor = rgba(230, 246, 254, 1);
    view.layer.cornerRadius = 10;
    
    
    CGFloat width = (SCREEN_WIDTH - 20) / 3;
    UILabel *leftLabel = [[UILabel alloc] init];
    [view addSubview:leftLabel];
    [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view).offset(0);
        make.top.equalTo(view).offset(0);
        make.bottom.equalTo(view).offset(0);
        make.width.mas_equalTo(@(width));
    }];
    leftLabel.text = @"张三";
    leftLabel.font = FONT(16);
    leftLabel.textColor = TEXT_COLOR;
    leftLabel.numberOfLines = 0;
    leftLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel *centerLabel = [[UILabel alloc] init];
    [view addSubview:centerLabel];
    [centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(view).offset(0);
        make.top.equalTo(view).offset(0);
        make.bottom.equalTo(view).offset(0);
        make.width.mas_equalTo(@(width));
    }];
    centerLabel.text = @"500";
    centerLabel.font = FONT(16);
    centerLabel.textColor = TEXT_COLOR;
    centerLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel *rightLabel = [[UILabel alloc] init];
    [view addSubview:rightLabel];
    [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(view).offset(0);
        make.top.equalTo(view).offset(0);
        make.bottom.equalTo(view).offset(0);
        make.width.mas_equalTo(@(width));
    }];
    rightLabel.text = @"待审查";
    rightLabel.font = FONT(16);
    rightLabel.textColor = BY_THEME_COLOR;
    rightLabel.textAlignment = NSTextAlignmentCenter;
    
    self.leftLabel = leftLabel;
    self.centerLabel = centerLabel;
    self.rightLabel = rightLabel;
}

- (void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;
    
    self.centerLabel.text = [NSString stringWithFormat:@"%@", netModel.money];
    if (BY_USER.isWorker.integerValue == 1) {
        if (netModel.audit_status.integerValue == 0) {
            self.rightLabel.text = @"待审查";
            self.rightLabel.textColor = [UIColor redColor];
        }else if (netModel.audit_status.integerValue == 1){
            self.rightLabel.text = @"已审阅";
            self.rightLabel.textColor = [UIColor grayColor];
        }else if (netModel.audit_status.integerValue == 2){
            self.rightLabel.text = @"存疑";
            self.rightLabel.textColor = [UIColor redColor];
        }
        self.leftLabel.text = netModel.overseer_name;
    }else{
        
        if (netModel.audit_status.integerValue == 0) {
            self.rightLabel.text = @"待审查";
            self.rightLabel.textColor = BY_THEME_COLOR;
        }else if (netModel.audit_status.integerValue == 1){
            self.rightLabel.text = @"已审阅";
            self.rightLabel.textColor = [UIColor grayColor];
        }else if (netModel.audit_status.integerValue == 2){
            self.rightLabel.text = @"存疑";
            self.rightLabel.textColor = [UIColor redColor];
        }
        self.leftLabel.text = netModel.worker_name;
    }
    
}
   

@end
